#include <stdio.h>
#include <stdlib.h>
#include "graph.h"

int main(void)
{
	Graph graph;

	Init(&graph);
	printf("初始化：\n");
	Show(&graph);

	InsertVertex(&graph, 'A');
	InsertVertex(&graph, 'B');
	InsertVertex(&graph, 'C');
	InsertVertex(&graph, 'D');
	InsertVertex(&graph, 'E');
	printf("插入顶点：\n");
	Show(&graph);

	InsertEdge(&graph, 'A', 'B');
	InsertEdge(&graph, 'A', 'D');
	InsertEdge(&graph, 'B', 'C');
	InsertEdge(&graph, 'B', 'E');
	InsertEdge(&graph, 'C', 'D');
	InsertEdge(&graph, 'C', 'E');
	printf("插入边：\n");
	Show(&graph);

	int pos = GetFirstNeighbor(&graph, 'A');
	printf("%c结点的第一个邻接顶点为：%c\n", 'A', graph.VertexList[pos]);
	pos = GetNextNeighbor(&graph, 'A', 'B');
	printf("%c结点过%c结点的下一个邻接顶点为：%c\n", 'A', 'B', graph.VertexList[pos]);

#if 0
     RemoveVertex1(&graph,'C');     //删除顶点：C 测试
     printf("方法1删除顶点：%c\n",'C');
     Show(&graph);
#endif

#if 1
	RemoveVertex2(&graph, 'C'); //删除顶点：C 测试
	printf("方法2删除顶点：%c\n", 'C');
	Show(&graph);
#endif

	printf("删除%c和%c之间的边：\n", 'A', 'B');
	RemoveEdge(&graph, 'A', 'B'); //删除边：A--B 测试
	Show(&graph);

	DestoryGraph(&graph);

	return 0;
}
